home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 16 / CU Amiga Magazine's Super CD-ROM 16 (1997-10-16)(EMAP Images)(GB)[!][issue 1997-11].iso / CUCD / Graphics / Ghostscript / source / gshtscr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-16  |  16.7 KB  |  530 lines

  1. /* Copyright (C) 1993, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gshtscr.c */
  20. /* Screen (Type 1) halftone processing for Ghostscript library */
  21. #include "math_.h"
  22. #include "gx.h"
  23. #include "gserrors.h"
  24. #include "gsstruct.h"
  25. #include "gxarith.h"
  26. #include "gzstate.h"
  27. #include "gxdevice.h"            /* for gzht.h */
  28. #include "gzht.h"
  29.  
  30. /* Define whether to force all halftones to be strip halftones, */
  31. /* for debugging. */
  32. #define FORCE_STRIP_HALFTONES 1
  33.  
  34. /* Structure descriptors */
  35. private_st_gs_screen_enum();
  36.  
  37. /* GC procedures */
  38. #define eptr ((gs_screen_enum *)vptr)
  39.  
  40. private ENUM_PTRS_BEGIN(screen_enum_enum_ptrs) {
  41.     if ( index < 2 + st_ht_order_max_ptrs )
  42.       { gs_ptr_type_t ret = (*st_ht_order.enum_ptrs)(&eptr->order, sizeof(eptr->order), index-2, pep);
  43.         if ( ret == 0 )    /* don't stop early */
  44.           ret = ptr_struct_type, *pep = 0;
  45.         return ret;
  46.       }
  47.     return (*st_halftone.enum_ptrs)(&eptr->halftone, sizeof(eptr->halftone), index-(2+st_ht_order_max_ptrs), pep);
  48.     }
  49.     ENUM_PTR(0, gs_screen_enum, pgs);
  50. ENUM_PTRS_END
  51.  
  52. private RELOC_PTRS_BEGIN(screen_enum_reloc_ptrs) {
  53.     RELOC_PTR(gs_screen_enum, pgs);
  54.     (*st_halftone.reloc_ptrs)(&eptr->halftone, sizeof(gs_halftone), gcst);
  55.     (*st_ht_order.reloc_ptrs)(&eptr->order, sizeof(gx_ht_order), gcst);
  56. } RELOC_PTRS_END
  57.  
  58. #undef eptr
  59.  
  60. /* Define the default value of AccurateScreens that affects */
  61. /* setscreen and setcolorscreen. */
  62. private bool screen_accurate_screens = false;
  63.  
  64. /* Default AccurateScreens control */
  65. void
  66. gs_setaccuratescreens(bool accurate)
  67. {    screen_accurate_screens = accurate;
  68. }
  69. bool
  70. gs_currentaccuratescreens(void)
  71. {    return screen_accurate_screens;
  72. }
  73.  
  74. /* Define the MinScreenLevels user parameter similarly. */
  75. private uint screen_min_screen_levels = 1;
  76.  
  77. void
  78. gs_setminscreenlevels(uint levels)
  79. {    screen_min_screen_levels = levels;
  80. }
  81. uint
  82. gs_currentminscreenlevels(void)
  83. {    return screen_min_screen_levels;
  84. }
  85.  
  86. /*
  87.  * The following implementation notes complement the general discussion of
  88.  * halftone tiles found in gxdht.h.
  89.  *
  90.  * Currently we allow R(') > 1 (i.e., multiple basic cells per multi-cell)
  91.  * only if AccurateScreens is true or if B (the number of pixels in a basic
  92.  * cell) < MinScreenLevels; if AccurateScreens is false and B >=
  93.  * MinScreenLevels, multi-cells and basic cells are the same.
  94.  *
  95.  * To find the smallest super-cell for a given multi-cell size, i.e., the
  96.  * smallest (absolute value) coordinates where the corners of multi-cells
  97.  * lie on the coordinate axes, we compute the values of i and j that give
  98.  * the minimum value of W by:
  99.  *    D = gcd(abs(M'), abs(N)), i = M'/D, j = N/D, W = C / D,
  100.  * and similarly
  101.  *    D' = gcd(abs(M), abs(N')), i' = N'/D', j' = M/D', W' = C / D'.
  102.  */
  103.  
  104. /* Compute the derived values of a halftone tile. */
  105. void
  106. gx_compute_cell_values(gx_ht_cell_params_t *phcp)
  107. {    const int M = phcp->M, N = phcp->N, M1 = phcp->M1, N1 = phcp->N1;
  108.     const uint m = any_abs(M), n = any_abs(N);
  109.     const uint m1 = any_abs(M1), n1 = any_abs(N1);
  110.     const ulong C = phcp->C = (ulong)m * m1 + (ulong)n * n1;
  111.     const int D = igcd(m1, n);
  112.     const int D1 = igcd(m, n1);
  113.     const uint W = phcp->W = C / D;
  114.     const uint W1 = phcp->W1 = C / D1;
  115.  
  116.     phcp->D = D, phcp->D1 = D1;
  117.     /* Compute the shift value. */
  118.     /* If M1 or N is zero, the shift is zero. */
  119.     if ( M1 && N )
  120.       {    int h = 0, k = 0, dy = 0;
  121.         int shift;
  122.  
  123.         /*
  124.          * There may be a faster way to do this: see Knuth vol. 2,
  125.          * section 4.5.2, Algorithm X (p. 302) and exercise 15
  126.          * (p. 315, solution p. 523).
  127.          */
  128.         while ( dy != D )
  129.           if ( dy > D )
  130.             { if ( M1 > 0 ) ++k;
  131.               else --k;
  132.               dy -= m1;
  133.             }
  134.           else
  135.             { if ( N > 0 ) ++h;
  136.               else --h;
  137.               dy += n;
  138.             }
  139.         shift = h * M + k * N1;
  140.         /* We just computed what amounts to a right shift; */
  141.         /* what we want is a left shift. */
  142.         phcp->S = imod(-shift, W);
  143.       }
  144.     else
  145.       phcp->S = 0;
  146.     if_debug12('h', "[h]MNR=(%d,%d)/%d, M'N'R'=(%d,%d)/%d => C=%lu, D=%d, D'=%d, W=%u, W'=%u, S=%d\n",
  147.            M, N, phcp->R, M1, N1, phcp->R1,
  148.            C, D, D1, W, W1, phcp->S);
  149. }
  150.  
  151. /* Forward references */
  152. private int pick_cell_size(P6(gs_screen_halftone *ph,
  153.   const gs_matrix *pmat, ulong max_size, uint min_levels, bool accurate,
  154.   gx_ht_cell_params_t *phcp));
  155.  
  156. /* Allocate a screen enumerator. */
  157. gs_screen_enum *
  158. gs_screen_enum_alloc(gs_memory_t *mem, client_name_t cname)
  159. {    return gs_alloc_struct(mem, gs_screen_enum, &st_gs_screen_enum, cname);
  160. }
  161.  
  162. /* Set up for halftone sampling. */
  163. int
  164. gs_screen_init(gs_screen_enum *penum, gs_state *pgs,
  165.   gs_screen_halftone *phsp)
  166. {    return gs_screen_init_accurate(penum, pgs, phsp,
  167.                        screen_accurate_screens);
  168. }
  169. int
  170. gs_screen_init_memory(gs_screen_enum *penum, gs_state *pgs,
  171.   gs_screen_halftone *phsp, bool accurate, gs_memory_t *mem)
  172. {    int code =
  173.       gs_screen_order_init_memory(&penum->order, pgs, phsp, accurate, mem);
  174.  
  175.     if ( code < 0 )
  176.       return code;
  177.     return
  178.       gs_screen_enum_init_memory(penum, &penum->order, pgs, phsp, mem);
  179. }
  180.  
  181. /* Allocate and initialize a spot screen. */
  182. /* This is the first half of gs_screen_init_accurate. */
  183. int
  184. gs_screen_order_init_memory(gx_ht_order *porder, const gs_state *pgs,
  185.   gs_screen_halftone *phsp, bool accurate, gs_memory_t *mem)
  186. {    gs_matrix imat;
  187.     ulong max_size = pgs->ht_cache->bits_size;
  188.     int code;
  189.  
  190.     if ( phsp->frequency < 0.1 )
  191.       return_error(gs_error_rangecheck);
  192.     gs_deviceinitialmatrix(gs_currentdevice(pgs), &imat);
  193.     code = pick_cell_size(phsp, &imat, max_size,
  194.                   screen_min_screen_levels, accurate,
  195.                   &porder->params);
  196.     if ( code < 0 )
  197.       return code;
  198.     gx_compute_cell_values(&porder->params);
  199. #if !FORCE_STRIP_HALFTONES
  200.     if ( porder->params.W1 <= max_size / bitmap_raster(porder->params.W) )
  201.       { /*
  202.          * Allocate an order for the entire tile, but only sample one
  203.          * strip.  Note that this causes the order parameters to be
  204.          * self-inconsistent until gx_ht_construct_spot_order fixes them
  205.          * up: see gxdht.h for more information.
  206.          */
  207.         code = gx_ht_alloc_order(porder, porder->params.W,
  208.                      porder->params.W1, 0,
  209.                      porder->params.W * porder->params.D,
  210.                      mem);
  211.         porder->height = porder->orig_height = porder->params.D;
  212.         porder->shift = porder->orig_shift = porder->params.S;
  213.       }
  214.     else
  215. #endif
  216.       { /* Just allocate the order for a single strip. */
  217.         code = gx_ht_alloc_order(porder, porder->params.W,
  218.                      porder->params.D, porder->params.S,
  219.                      porder->params.W * porder->params.D,
  220.                      mem);
  221.       }
  222.     if ( code < 0 )
  223.       return code;
  224.     return 0;
  225. }
  226.  
  227. /*
  228.  * Given a desired frequency, angle, and minimum number of levels, a maximum
  229.  * cell size, and an AccurateScreens flag, pick values for M('), N('), and
  230.  * R(').  We want to get a good fit to the requested frequency and angle,
  231.  * provide at least the requested minimum number of levels, and keep
  232.  * rendering as fast as possible; trading these criteria off against each
  233.  * other is what makes the code complicated.
  234.  *
  235.  * We compute trial values u and v from the original values of F and A.
  236.  * Normally these will not be integers.  We then examine the 4 pairs of
  237.  * integers obtained by rounding each of u and v independently up or down,
  238.  * and pick the pair U, V that yields the closest match to the requested
  239.  * F and A values and doesn't require more than max_size storage for a
  240.  * single tile.  If no pair
  241.  * yields an acceptably small W, we divide both u and v by 2 and try again.
  242.  * Then we run the equations backward to obtain the actual F and A.
  243.  * This is fairly easy given that we require either xx = yy = 0 or
  244.  * xy = yx = 0.  In the former case, we have
  245.  *    U = (72 / F * xx) * cos(A);
  246.  *    V = (72 / F * yy) * sin(A);
  247.  * from which immediately
  248.  *    A = arctan((V / yy) / (U / xx)),
  249.  * or equivalently
  250.  *    A = arctan((V * xx) / (U * yy)).
  251.  * We can then obtain F as
  252.  *    F = (72 * xx / U) * cos(A),
  253.  * or equivalently
  254.  *    F = (72 * yy / V) * sin(A).
  255.  * For landscape devices, we replace xx by yx, yy by xy, and interchange
  256.  * sin and cos, resulting in
  257.  *    A = arctan((U * xy) / (V * yx))
  258.  * and
  259.  *    F = (72 * yx / U) * sin(A)
  260.  * or
  261.  *    F = (72 * xy / V) * cos(A).
  262.  */
  263. /* ph->frequency and ph->angle are input parameters; */
  264. /* the routine sets ph->actual_frequency and ph->actual_angle. */
  265. private int
  266. pick_cell_size(gs_screen_halftone *ph, const gs_matrix *pmat, ulong max_size,
  267.   uint min_levels, bool accurate, gx_ht_cell_params_t *phcp)
  268. {    const bool landscape = (pmat->xy != 0.0 || pmat->yx != 0.0);
  269.     /* Account for a possibly reflected coordinate system. */
  270.     /* See gxstroke.c for the algorithm. */
  271.     const bool reflected = pmat->xy * pmat->yx > pmat->xx * pmat->yy;
  272.     const int reflection = (reflected ? -1 : 1);
  273.     const int rotation =
  274.       (landscape ? (pmat->yx < 0 ? 90 : -90) : pmat->xx < 0 ? 180 : 0);
  275.     const double f0 = ph->frequency, a0 = ph->angle;
  276.     const double T =
  277.       fabs((landscape ? pmat->yx / pmat->xy : pmat->xx / pmat->yy));
  278.     gs_point uv0;
  279. #define u0 uv0.x
  280. #define v0 uv0.y
  281.     int rt = 1;
  282.     double f = 0, a = 0;
  283.     double e_best = 1000;
  284.     bool better;
  285.  
  286.     /*
  287.      * We need to find a vector in device space whose length is
  288.      * 1 inch / ph->frequency and whose angle is ph->angle.
  289.      * Because device pixels may not be square, we can't simply
  290.      * map the length to device space and then rotate it;
  291.      * instead, since we know that user space is uniform in X and Y,
  292.      * we calculate the correct angle in user space before rotation.
  293.      */
  294.  
  295.     /* Compute trial values of u and v. */
  296.  
  297.     { gs_matrix rmat;
  298.       gs_make_rotation(a0 * reflection + rotation, &rmat);
  299.       gs_distance_transform(72.0 / f0, 0.0, &rmat, &uv0);
  300.       gs_distance_transform(u0, v0, pmat, &uv0);
  301.       if_debug10('h', "[h]Requested: f=%g a=%g mat=[%g %g %g %g] max_size=%lu min_levels=%u =>\n     u=%g v=%g\n",
  302.              ph->frequency, ph->angle,
  303.              pmat->xx, pmat->xy, pmat->yx, pmat->yy,
  304.              max_size, min_levels, u0, v0);
  305.     }
  306.  
  307.     /* Adjust u and v to reasonable values. */
  308.  
  309.     if ( u0 == 0 && v0 == 0 )
  310.       return_error(gs_error_rangecheck);
  311.     while ( (fabs(u0) + fabs(v0)) * rt < 4 )
  312.       ++rt;
  313. try_size:
  314.     better = false;
  315.     { int m0 = (int)floor(u0 * rt + 0.0001);
  316.       int n0 = (int)floor(v0 * rt + 0.0001);
  317.       gx_ht_cell_params_t p;
  318.  
  319.       p.R = p.R1 = rt;
  320.       for ( p.M = m0 + 1; p.M >= m0; p.M-- )
  321.         for ( p.N = n0 + 1; p.N >= n0; p.N-- )
  322.           {    long raster, wt, wt_size;
  323.         double fr, ar, ft, at, f_diff, a_diff, f_err, a_err;
  324.  
  325.         p.M1 = (int)(p.M / T + 0.5);
  326.         p.N1 = (int)(p.N * T + 0.5);
  327.         gx_compute_cell_values(&p);
  328.         if_debug3('h', "[h]trying m=%d, n=%d, r=%d\n", p.M, p.N, rt);
  329.         wt = p.W;
  330.         if ( wt >= max_short )
  331.           continue;
  332.         /* Check the strip size, not the full tile size, */
  333.         /* against max_size. */
  334.         raster = bitmap_raster(wt);
  335.         if ( raster > max_size / p.D || raster > max_long / wt )
  336.           continue;
  337.         wt_size = raster * wt;
  338.  
  339.         /* Compute the corresponding values of F and A. */
  340.  
  341.         if ( landscape )
  342.           ar = atan2(p.M * pmat->xy, p.N * pmat->yx),
  343.           fr = 72.0 * (p.M == 0 ? pmat->xy / p.N * cos(ar) :
  344.                    pmat->yx / p.M * sin(ar));
  345.         else
  346.           ar = atan2(p.N * pmat->xx, p.M * pmat->yy),
  347.           fr = 72.0 * (p.M == 0 ? pmat->yy / p.N * sin(ar) :
  348.                    pmat->xx / p.M * cos(ar));
  349.         ft = fabs(fr) * rt;
  350.         /* Normalize the angle to the requested quadrant. */
  351.         at = (ar * radians_to_degrees - rotation) * reflection;
  352.         at -= floor(at / 180.0) * 180.0;
  353.         at += floor(a0 / 180.0) * 180.0;
  354.         f_diff = fabs(ft - f0);
  355.         a_diff = fabs(at - a0);
  356.         f_err = f_diff / fabs(f0);
  357.         /*
  358.          * We used to compute the percentage difference here:
  359.          *    a_err = (a0 == 0 ? a_diff : a_diff / fabs(a0));
  360.          * but using the angle difference makes more sense:
  361.          */
  362.         a_err = a_diff;
  363.  
  364.         if_debug5('h', " ==> d=%d, wt=%ld, wt_size=%ld, f=%g, a=%g\n",
  365.               p.D, wt, bitmap_raster(wt) * wt, ft, at);
  366.  
  367.         /*
  368.          * Minimize angle and frequency error within the
  369.          * permitted maximum super-cell size.
  370.          */
  371.  
  372.         { double err = f_err * a_err;
  373.           if ( err > e_best )
  374.             continue;
  375.           e_best = err;
  376.         }
  377.         *phcp = p;
  378.         f = ft, a = at;
  379.         better = true;
  380.         if_debug3('h', "*** best wt_size=%ld, f_diff=%g, a_diff=%g\n",
  381.               wt_size, f_diff, a_diff);
  382.         if ( f_err <= 0.01 && a_err <= 0.01 )
  383.           goto done;
  384.           }
  385.     }
  386.     if ( phcp->C < min_levels )
  387.       {    /* We don't have enough levels yet.  Keep going. */
  388.         ++rt;
  389.         goto try_size;
  390.       }
  391.     if ( better )
  392.       {    /* If we want accurate screens, continue till we fail. */
  393.         if ( accurate )
  394.           { ++rt;
  395.             goto try_size;
  396.           }
  397.       }
  398.     else
  399.       {    /*
  400.          * We couldn't find an acceptable M and N.  If R > 1,
  401.          * take what we've got; if R = 1, give up.
  402.          */
  403.         if ( rt == 1 )
  404.           return_error(gs_error_rangecheck);
  405.       }
  406.  
  407.     /* Deliver the results. */
  408. done:
  409.     if_debug5('h', "[h]Chosen: f=%g a=%g M=%d N=%d R=%d\n",
  410.           f, a, phcp->M, phcp->N, phcp->R);
  411.     ph->actual_frequency = f;
  412.     ph->actual_angle = a;
  413.     return 0;
  414. #undef u0
  415. #undef v0
  416. }
  417.  
  418. /* Prepare to sample a spot screen. */
  419. /* This is the second half of gs_screen_init_accurate. */
  420. int
  421. gs_screen_enum_init_memory(gs_screen_enum *penum, const gx_ht_order *porder,
  422.   gs_state *pgs, gs_screen_halftone *phsp, gs_memory_t *mem)
  423. {    penum->pgs = pgs;        /* ensure clean for GC */
  424.     penum->order = *porder;
  425.     penum->halftone.rc.memory = mem;
  426.     penum->halftone.type = ht_type_screen;
  427.     penum->halftone.params.screen = *phsp;
  428.     penum->x = penum->y = 0;
  429.     penum->strip = porder->num_levels / porder->width;
  430.     penum->shift = porder->shift;
  431.     /*
  432.      * We want a transformation matrix that maps the parallelogram
  433.      * (0,0), (U,V), (U-V',V+U'), (-V',U') to the square (+/-1, +/-1).
  434.      * If the coefficients are [a b c d e f] and we let
  435.      *    u = U = M/R, v = V = N/R,
  436.      *    r = -V' = -N'/R', s = U' = M'/R',
  437.      * then we just need to solve the equations:
  438.      *    a*0 + c*0 + e = -1    b*0 + d*0 + f = -1
  439.      *    a*u + c*v + e = 1    b*u + d*v + f = 1
  440.      *    a*r + c*s + e = -1    b*r + d*s + f = 1
  441.      * This has the following solution:
  442.      *    Q = 2 / (M*M' + N*N')
  443.      *    a = Q * R * M'
  444.      *    b = -Q * R' * N
  445.      *    c = Q * R * N'
  446.      *    d = Q * R' * M
  447.      *    e = -1
  448.      *    f = -1
  449.      */
  450.     { const int M = porder->params.M, N = porder->params.N,
  451.         R = porder->params.R;
  452.       const int M1 = porder->params.M1, N1 = porder->params.N1,
  453.         R1 = porder->params.R1;
  454.       double Q = 2.0 / ((long)M * M1 + (long)N * N1);
  455.       penum->mat.xx = Q * (R * M1);
  456.       penum->mat.xy = Q * (-R1 * N);
  457.       penum->mat.yx = Q * (R * N1);
  458.       penum->mat.yy = Q * (R1 * M);
  459.       penum->mat.tx = -1.0;
  460.       penum->mat.ty = -1.0;
  461.     }
  462.     if_debug7('h', "[h]Screen: (%dx%d)/%d [%f %f %f %f]\n",
  463.           porder->width, porder->height, porder->params.R,
  464.           penum->mat.xx, penum->mat.xy,
  465.           penum->mat.yx, penum->mat.yy);
  466.     return 0;
  467. }
  468.  
  469. /* Report current point for sampling */
  470. int
  471. gs_screen_currentpoint(gs_screen_enum *penum, gs_point *ppt)
  472. {    gs_point pt;
  473.     int code;
  474.     if ( penum->y >= penum->strip )        /* all done */
  475.     {    gx_ht_construct_spot_order(&penum->order);
  476.         return 1;
  477.     }
  478.     /* We displace the sampled coordinates very slightly */
  479.     /* in order to reduce the likely number of points */
  480.     /* for which the spot function returns the same value. */
  481.     if ( (code = gs_point_transform(penum->x + 0.501, penum->y + 0.498, &penum->mat, &pt)) < 0 )
  482.         return code;
  483.     if ( pt.x < -1.0 )
  484.         pt.x += ((int)(-ceil(pt.x)) + 1) & ~1;
  485.     else if ( pt.x >= 1.0 )
  486.         pt.x -= ((int)pt.x + 1) & ~1;
  487.     if ( pt.y < -1.0 )
  488.         pt.y += ((int)(-ceil(pt.y)) + 1) & ~1;
  489.     else if ( pt.y >= 1.0 )
  490.         pt.y -= ((int)pt.y + 1) & ~1;
  491.     *ppt = pt;
  492.     return 0;
  493. }
  494.  
  495. /* Record next halftone sample */
  496. int
  497. gs_screen_next(gs_screen_enum *penum, floatp value)
  498. {    ht_sample_t sample;
  499.     int width = penum->order.width;
  500.     if ( value < -1.0 || value > 1.0 )
  501.         return_error(gs_error_rangecheck);
  502.     /* The following statement was split into two */
  503.     /* to work around a bug in the Siemens C compiler. */
  504.     sample = (ht_sample_t)(value * max_ht_sample);
  505.     sample += max_ht_sample;    /* convert from signed to biased */
  506. #ifdef DEBUG
  507. if ( gs_debug_c('H') )
  508.    {    gs_point pt;
  509.     gs_screen_currentpoint(penum, &pt);
  510.     dprintf6("[H]sample x=%d y=%d (%f,%f): %f -> %u\n",
  511.          penum->x, penum->y, pt.x, pt.y, value, sample);
  512.    }
  513. #endif
  514.     penum->order.bits[penum->y * width + penum->x].mask = sample;
  515.     if ( ++(penum->x) >= width )
  516.         penum->x = 0, ++(penum->y);
  517.     return 0;
  518. }
  519.  
  520. /* Install a fully constructed screen in the gstate. */
  521. int
  522. gs_screen_install(gs_screen_enum *penum)
  523. {    gx_device_halftone dev_ht;
  524.  
  525.     dev_ht.rc.memory = penum->halftone.rc.memory;
  526.     dev_ht.order = penum->order;
  527.     dev_ht.components = 0;
  528.     return gx_ht_install(penum->pgs, &penum->halftone, &dev_ht);
  529. }
  530.